package edu.bit.water.controller;


import edu.bit.water.entity.MetaLimit;
import edu.bit.water.entity.WasteWaterSub;
import edu.bit.water.service.WasteWaterSubService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/waste_water_sub")
public class WasteWaterSubController {
    @Autowired
    private WasteWaterSubService wasteWaterSubService;

    @RequestMapping("/get_meta_data")
    @ResponseBody
    public List<MetaLimit> getMetaData(String stdNumber) {
        return wasteWaterSubService.getMetaData(stdNumber);
    }

    @RequestMapping("/select")
    @ResponseBody
    public List<WasteWaterSub> select(int lastId) {
        return wasteWaterSubService.select(lastId);
    }

    @RequestMapping("/insert")
    @ResponseBody
    public void insert(WasteWaterSub wasteWaterSub) {
        wasteWaterSubService.insert(wasteWaterSub);
    }

    @RequestMapping("/update")
    @ResponseBody
    public void update(WasteWaterSub wasteWaterSub) {
        wasteWaterSubService.update(wasteWaterSub);
    }

    @RequestMapping("/delete")
    @ResponseBody
    public void delete(@RequestBody List<Integer> ids) {
//        for (int id :
//                ids) {
//            System.out.println(id);
//        }
        wasteWaterSubService.delete(ids);
    }

    @RequestMapping("/update_state")
    @ResponseBody
    public void updateState(String state, int id) {
        wasteWaterSubService.updateState(state, id);
    }
}
